package com.daxia.wx.dto;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.LinkedHashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.daxia.bumall.util.BigDecimalUtils;


public class WxOrderMessageTemplate extends WxMessageTemplate {
    private String title = "";
    private String nickName;
    private String orderNo;
    private double amount;
    private String productInfo;
    
    @Override
    public String getTemplateId() {
        return "Pnj2ATgV-EoPthMWTB7FO6Ja3i-Yeavg_dGd2h5plYU";
    }

    @Override
    public String toJson() {
        JSONObject json = new JSONObject();
        json.put("touser", getOpenid());
        json.put("template_id", getTemplateId());
        json.put("url", "");

        JSONObject data = new JSONObject();

        JSONObject first = new JSONObject();
        first.put("value", getTitle());
        //first.put("color", color);
        data.put("first", first);
    
        Map<String, String> keywordMap = new LinkedHashMap<String, String>();
        keywordMap.put("keyword1", getNickName());
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        keywordMap.put("keyword2", getOrderNo());
        BigDecimal b = BigDecimalUtils.formatMoney(amount);
        keywordMap.put("keyword3", "￥" + b.toString());
        keywordMap.put("keyword4", getProductInfo());
        for (String key : keywordMap.keySet()) {
            JSONObject keyword = new JSONObject();
            keyword.put("value", keywordMap.get(key));
            data.put(key, keyword);
        }

        data.put("remark", "");

        json.put("data", data);
        
        return json.toJSONString();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getProductInfo() {
        return productInfo;
    }

    public void setProductInfo(String productInfo) {
        this.productInfo = productInfo;
    }
    
    

}
